﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    public class ElectricCar : Car, IElectricBased
    {
        private const float k_MaximumBatteryTime = 3.5f;
        private ElectricEngine m_ElectricEngine;

        public ElectricCar()
        {
            m_ElectricEngine = new ElectricEngine(0.0f, k_MaximumBatteryTime);
        }

        public override void ParseFields(Dictionary<string, string> i_Form)
        {
            base.ParseFields(i_Form);
            float percentage = (float.Parse(RemainingEnergyPercentage) / 100) * ElectricEnergySource.MaximumBattreyTime;
            RemainingEnergyPercentage = percentage.ToString();
        }

        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.ToString());
            stringBuilder.Append(m_ElectricEngine.ToString());

            return stringBuilder.ToString();
        }

        public ElectricEngine ElectricEnergySource
        {
            get { return m_ElectricEngine; }
        }

        public void Recharge(float i_TimeToAdd, ref Vehicle io_Vehicle)
        {
            m_ElectricEngine.Recharge(i_TimeToAdd, ref io_Vehicle);
        }
    }
}
